GTK+ Gnome Application Development by Havoc Pennington
Author:Havoc Pennington
Language: eng
Format: mobi, pdf
Publisher: UNKNOWN
Published: 2018-06-18T23:00:00+00:00
Chaining Up
If an object overrides the shutdown, destroy, or finalize methods, it should chain up to the default implementation, to ensure that each parent class has a chance to clean up. Here is an example of chaining up:
static void
gtk_widget_real_destroy (GtkObject *object)
{
/* ... */ if (parent_class
>destroy)
parent_class>destroy (object);
};
gtk_widget_real_destroy() is installed in the widget’s class struct in the class initialization function, overwriting the GtkObject default. parent_class is a pointer to the parent’s class struct; usually you will want to store this pointer in your class initialization function, as GtkWidget does:
static GtkObjectClass *parent_class = NULL;
/* ... code omitted ... */
static void
gtk_widget_class_init (GtkWidgetClass *klass) {
GtkObjectClass *object_class;
object_class = (GtkObjectClass*) klass;
parent_class = gtk_type_class (gtk_object_get_type ()); /* ... code omitted ... */
object_class>set_arg = gtk_widget_set_arg; object_class>get_arg = gtk_widget_get_arg; object_class>shutdown = gtk_widget_shutdown; object_class>destroy = gtk_widget_real_destroy; object_class>finalize = gtk_widget_finalize;
}
Of course, if parent_class is not a GtkObjectClass*, you will need to cast it with the GTK_OBJECT_CLASS() macro.
An aside: notice that you should not chain up when implementing get_arg and set_arg — GTK+ special-cases these methods ingtk_object_set() andgtk_object_get(). Recall that the GtkObject base class initializer zeroes these two methods, rather than leaving the default implementation. When setting or getting an argument value, GTK+ uses the information provided on argument registration to jump directly to the correct class struct and invoke only the correct get_arg or set_arg method. Chaining up would be a much slower way to implement the same thing (and would require unique argument IDs within the same class ancestry).
Download
GTK+ Gnome Application Development by Havoc Pennington.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(25282)
Hello! Python by Anthony Briggs(24335)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(23421)
Kotlin in Action by Dmitry Jemerov(22504)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(21961)
Dependency Injection in .NET by Mark Seemann(21838)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(20707)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(19517)
Grails in Action by Glen Smith Peter Ledbrook(18595)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17031)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(15836)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(13684)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(11851)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11151)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10621)
Hit Refresh by Satya Nadella(9188)
The Kubernetes Operator Framework Book by Michael Dame(8563)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8400)
Robo-Advisor with Python by Aki Ranin(8358)